﻿using Microsoft.Xna.Framework;

namespace block_explorer
{
    class Camera
    {
        private Matrix mView;
        private Matrix mProjection;

        private bool mUpdateFrustum;
        private BoundingFrustum mFrustum;

        public virtual Matrix View { get { return mView; } set { mView = value; mUpdateFrustum = true; } }
        public virtual Matrix Projection { get { return mProjection; } set { mProjection = value; mUpdateFrustum = true; } }
        public BoundingFrustum Frustum { get { if (mUpdateFrustum) UpdateFrustum(); return mFrustum; } }

        public Camera()
        {
            mView = Matrix.Identity;
            mProjection = Matrix.Identity;
            mUpdateFrustum = true;
            mFrustum = null;
        }

        private void UpdateFrustum()
        {
            mFrustum = new BoundingFrustum(mView * mProjection);
            mUpdateFrustum = false;
        }
    }
}
